INCLUDE(PythonEnvironment)
GET_PYTHON_ENV()

FOREACH(TEST_SRC ${INTEGRATION_TESTS})
	STRING(REGEX REPLACE ".*/(.*).m" "\\1" TEST_NAME ${TEST_SRC})
	SET(EXEC_EXECUTABLE ${PYTHON_EXECUTABLE})
	SET(EXEC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/test_one.py)
	SET(EXEC_ARGS ${TEST_SRC})
	add_test(NAME integration-python_modular-${TEST_NAME}
		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
		COMMAND ${CMAKE_COMMAND}
		-DEXECUTABLE=${EXEC_EXECUTABLE}
		-DFILE=${EXEC_FILE}
		-DARGS=${EXEC_ARGS}
		-DGDB_COMMAND=${GDB_COMMAND}
		-DGDB_SCRIPT=${GDB_DEFAULT_SCRIPT}
		-P ${CMAKE_MODULE_PATH}/checkgdb.cmake)
	set_property(TEST integration-python_modular-${TEST_NAME} PROPERTY
		ENVIRONMENT "${PYTHON_ENV_VARS}")
ENDFOREACH()

FILE(GLOB PYTHON_MODULAR_INTEGRATION_TESTS tests/*.py)
FOREACH(TEST_SRC ${PYTHON_MODULAR_INTEGRATION_TESTS})
	STRING(REGEX REPLACE ".*/(.*).py" "\\1" TEST_NAME ${TEST_SRC})
	SET(EXEC_EXECUTABLE ${PYTHON_EXECUTABLE})
	SET(EXEC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tester.py)
	SET(EXEC_ARGS ${TEST_NAME}.py)
	add_test(NAME integration-python_modular-tester-${TEST_NAME}
		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
		COMMAND ${CMAKE_COMMAND}
		-DEXECUTABLE=${EXEC_EXECUTABLE}
		-DFILE=${EXEC_FILE}
		-DARGS=${EXEC_ARGS}
		-DGDB_COMMAND=${GDB_COMMAND}
		-DGDB_SCRIPT=${GDB_DEFAULT_SCRIPT}
		-P ${CMAKE_MODULE_PATH}/checkgdb.cmake)
	set_property(TEST integration-python_modular-tester-${TEST_NAME} PROPERTY
		ENVIRONMENT "${PYTHON_ENV_VARS}")
ENDFOREACH()
